#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std;
#define int long long 
vector<pair<int, int>> a;
unordered_map<int, bool> r;
unordered_map<int, bool> l;
signed main() {
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < k; i++) {
        int x, y;
        cin >> x >> y;
        a.push_back({x, y});
    }
    int sum = 0;
    int x = 0, y = 0;
    for(auto& [a, b] : a) {
        if(r[a] == false) {
            x++;
            r[a] = true;
        }
        if(l[b] == false) {
            y++;
            l[b] = true;
        }
    }  
    sum = n * x + n * y - x * y;
    cout << sum << endl;
    return 0;
}